home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
list
/
list.c
next >
Wrap
C/C++ Source or Header
|
1989-01-17
|
907b
|
49 lines
#include <\c\include\stdio.h>
#define MAXWORD 100
/* Source is from Advanced C by H. Schildt 1988. */
main()
{
char *find_next(), word[MAXWORD];
int char_cnt=0, word_cnt = 0, word_length = 0;
while (find_next(word) != NULL)
{
capitalize(word);
++word_cnt;
word_length = strlen(word);
char_cnt += word_length;
printf("\n%12d %s", word_length, word);
}
printf("\n\n%12d characters in %d words\n\n", char_cnt, word_cnt);
}
char *find_next(word)
char word[];
{
int c,i;
while ((c = getchar()) == ' ' || c=='\n' || c == '\t');
if (c != EOF)
{
i =0;
while (c != ' ' && c != '\n' && c != '\t' && c != EOF)
{
word[i++] = c;
c = getchar();
}
word[i] = '\0';
return (word);
}
else
return (NULL);
}
capitalize (p)
char *p;
{
for (; *p != '\0'; ++p)
if ('a' <= *p && *p <= 'z')
*p += 'A' - 'a';
}